package com.kunbo.cn.app.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.kunbo.cn.entity.core.handset.HandsetUsers;
import com.kunbo.cn.service.core.handset.HandsetUsersService;

import com.kunbo.cn.util.retu.CommonResult;


@RestController
@RequestMapping("/handset")
public class HandsetController {

	@Resource
	private HandsetUsersService husService;

	@RequestMapping("/login")
	public  CommonResult login(HttpServletRequest request, HttpSession session) {
		String name = request.getParameter("userName");
		String password = request.getParameter("password");
		if(StringUtils.isBlank(name)) {
			return new CommonResult(false, "用户名不可为空，请输入", null);
		}
		if(StringUtils.isBlank(password)) {
			return new CommonResult(false, "密码不可为空，请输入", null);
		}
		HandsetUsers hu = husService.findCurrentAccount(name, password);
		if (null == hu) {
			return new CommonResult(false, "用户名或者密码错误", null);
		} else {
			session.setAttribute("handsetUser", hu);
			return new CommonResult(true, "验证通过", hu);
		}
	}
	

	
	

	
	
	
	

}
